﻿#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;

struct PersonRef
{
	int m_Age;
};
void allocateMemory(PersonRef** p)
{
	//1.**p，具体的PersonRef对象；*p，对象的指针；p，指针的指针；
	*p = (PersonRef*)malloc(sizeof(PersonRef));
	(*p)->m_Age = 100;
}
void allocateMemoryRef(PersonRef*& p)
{
	p = (PersonRef*)malloc(sizeof(PersonRef));
	p->m_Age = 200;
}
void testPointerRef()
{
	PersonRef* p = NULL;
	allocateMemory(&p);
	cout << "p的年龄为：" << p->m_Age << endl;//100

	allocateMemoryRef(p);
	cout << "p的年龄为：" << p->m_Age << endl;//200
}

//main243：指针的引用
int main243()
{
	testPointerRef();

	system("pause");
	return EXIT_SUCCESS;
}